Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / Object Class Definitions


Container

An object of class Container is any Finder container, such as a folder, a disk, or the Trash.

PROPERTIES
A container has all the properties defined for object class object class Item on page 72: Bounds, Comment, Container, Content Space, Creation Date, Disk, Folder, Icon, ID, Information Window, Kind, Label Index, Modification Date, Name, Physical Size, Position, Selected, Size, and Window.

Unlike other items, a container also has these properties:

completely expanded
A Boolean value that indicates whether a container and any folders it contains are completed expanded in list view (true) or not (false). For a container to be completely expanded, the window that contains the container must be open in list view (that is, any item other than "by Small Icon" or "by Icon" is selected in the Views menu for the window), the container and all nested folders within the it must be fully expanded with that same list view, and the container's own window must be closed. Before you can set this property, the window that contains the container must already be open in a list view.
Class: Boolean
Modifiable: Yes
container window
A reference to the container's window.
Class:
Modifiable: No
entire contents
A list of references to the entire contents of the container, including the contents of any other containers within
the container.
Class: List of references
Modifiable: No
expandable
A Boolean value that indicates whether the container can
be opened within its container in outline view (true) or
not (false).
Class: Boolean
Modifiable: No
expanded
A Boolean value that indicates whether the item is open in outline view (true) or not (false).
Class: Boolean
Modifiable: Yes
previous list view
An integer between 2 and 8 or one of the corresponding constants name, modification date, size, kind, comment, label index, or version. If the View property of the container is currently one of these list views, the value of this property is the current list view. If the View property is small icon or icon, the value of this property is the last list view selected. If no list view has been selected since the container was first opened, the value of this property is name. You can't get or set this property unless the container is open, and the value of the property isn't retained after the container has been closed.
Class: Integer
Modifiable: No
selection
A list of references to the container elements that are currently selected. The elements in the selection are those that would
be cut by a Cut command or copied by a Copy command. If no elements are selected, the value of the Selection property is
an empty list.
Class: List of references
Modifiable: Yes
view
An integer between 0 and 8 or one of the corresponding constants small icon, icon, name, modification date, size, kind, comment, label index, or version, indicating the current selection in the View menu for the container's window. You can't get or set this property unless the container is open.
Class: Integer
Modifiable: Yes
ELEMENT CLASSES
Objects of these classes can be identified at the top level of a container by name or by number. Page numbers indicate the location of corresponding definitions in this chapter.

Accessory Suitcase (page 27)
Alias File (page 28)
Application File (page 38)
Container (page 42)
Control Panel (page 51)
Desk Accessory File (page 54)
Document File (page 59)
File (page 60)
Folder (page 62)
Font File (page 64)
Font Suitcase (page 65)
Item (page 72)
Sharable Container (page 78)
Sound File (page 86)
Suitcase (page 88)
COMMANDS HANDLED
Clean Up, Close, Copy, Count, Data Size, Delete, Duplicate, Exists, Get, Move, Open, Put Away, Reveal, Select, Sort, Update

DEFAULT VALUE CLASS RETURNED
A reference to a container or, if you use the plural form containers, a list
of references.

EXAMPLES
The first example opens all the containers on the desktop except for the Trash.

tell application "Finder"   open (containers in desktop whose name is not "Trash")
end tell
The next example, if saved as a script application, toggles the value of the Completely Expanded property of all containers at the top level of the front window: that is, it alternately expands all the containers and their nested containers or collapses them. The window in which the script application
is located must be open in list view for the script to work on the window's contents.

property expan : false

tell application "Finder"   if expan = false then
      set completely expanded of containers in ¬
         container of front window to true
      set expan to true
   else
      set completely expanded of containers in ¬
         container of front window to false
      set expan to false
   end if
end tell
The script begins by declaring the value of the expan property to be false. This property is a Boolean value that changes after the script is run. The
script sets expan to true whenever it sets the Completely Expanded
property of the front window's containers to true, or to false whenever
it sets their Completely Expanded property to false.

The value of the property container of front window is a reference to the container to which the window belongs. This script must specify the Container property of the window, rather than the window itself, or it may not work consistently. A window's container always has a fixed number of elements until new elements are added or deleted, whereas a window open in list view has a variable number of elements depending on which folders are expanded.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996